package com.fss.article1.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fss.common.annotation.Log;
import com.fss.common.core.controller.BaseController;
import com.fss.common.core.domain.AjaxResult;
import com.fss.common.enums.BusinessType;
import com.fss.article1.domain.Article1;
import com.fss.article1.service.IArticle1Service;
import com.fss.common.utils.poi.ExcelUtil;
import com.fss.common.core.page.TableDataInfo;

/**
 * article1Controller
 * 
 * @author llf
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/article1/article1")
public class Article1Controller extends BaseController
{
    @Autowired
    private IArticle1Service article1Service;

    /**
     * 查询article1列表
     */
    @PreAuthorize("@ss.hasPermi('article1:article1:list')")
    @GetMapping("/list")
    public TableDataInfo list(Article1 article1)
    {
        startPage();
        List<Article1> list = article1Service.selectArticle1List(article1);
        return getDataTable(list);
    }

    /**
     * 导出article1列表
     */
    @PreAuthorize("@ss.hasPermi('article1:article1:export')")
    @Log(title = "article1", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Article1 article1)
    {
        List<Article1> list = article1Service.selectArticle1List(article1);
        ExcelUtil<Article1> util = new ExcelUtil<Article1>(Article1.class);
        util.exportExcel(response, list, "article1数据");
    }

    /**
     * 获取article1详细信息
     */
    @PreAuthorize("@ss.hasPermi('article1:article1:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(article1Service.selectArticle1ById(id));
    }

    /**
     * 新增article1
     */
    @PreAuthorize("@ss.hasPermi('article1:article1:add')")
    @Log(title = "article1", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Article1 article1)
    {
        return toAjax(article1Service.insertArticle1(article1));
    }

    /**
     * 修改article1
     */
    @PreAuthorize("@ss.hasPermi('article1:article1:edit')")
    @Log(title = "article1", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Article1 article1)
    {
        return toAjax(article1Service.updateArticle1(article1));
    }

    /**
     * 删除article1
     */
    @PreAuthorize("@ss.hasPermi('article1:article1:remove')")
    @Log(title = "article1", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(article1Service.deleteArticle1ByIds(ids));
    }
}
